Barometer 4 Click
Barometer 4 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Nenad Filipovic
- Date : Sep 2021.
- Type : I2C type
Software Support
Example Description
This library contains API for the Barometer 4 Click driver. The library initializes and defines the I2C bus drivers to write and read data from registers. This demo application shows an example of atmospheric pressure and temperature measurement.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Barometer4
Example Key Functions
- barometer4_cfg_setup Config Object Initialization function.
void barometer4_cfg_setup(barometer4_cfg_t *cfg)
Barometer 4 configuration object setup function.
Barometer 4 Click configuration object.
Definition barometer4.h:155
- barometer4_init Initialization function.
err_t barometer4_init(barometer4_t *ctx, barometer4_cfg_t *cfg)
Barometer 4 initialization function.
Barometer 4 Click context object.
Definition barometer4.h:141
- barometer4_default_cfg Click Default Configuration function.
err_t barometer4_default_cfg(barometer4_t *ctx)
Barometer 4 default configuration function.
- barometer4_get_pressure_and_temperature Barometer 4 get pressure and temperature function.
err_t barometer4_get_pressure_and_temperature(barometer4_t *ctx, float *pressure, float *temperature)
Barometer 4 get pressure and temperature function.
- barometer4_get_raw_data Barometer 4 get RAW data function.
err_t barometer4_get_raw_data(barometer4_t *ctx, uint16_t measurement_comd, uint32_t *pressure, uint16_t *temperature)
Barometer 4 get RAW data function.
- barometer4_soft_reset Barometer 4 software reset function.
err_t barometer4_soft_reset(barometer4_t *ctx)
Barometer 4 software reset function.
Application Init
The initialization of the I2C module and log UART. After driver initialization and default settings, the app display device ID.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "----------------------------\r\n" );
Delay_ms ( 100 );
static uint16_t device_id;
{
log_error( &logger, " Communication Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " Device ID : 0x%.4X \r\n", device_id );
log_printf( &logger, "----------------------------\r\n" );
Delay_ms ( 1000 );
}
@ BAROMETER4_ERROR
Definition barometer4.h:189
#define BAROMETER4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition barometer4.h:129
err_t barometer4_get_device_id(barometer4_t *ctx, uint16_t *device_id)
Barometer 4 get device ID function.
void application_init(void)
Definition main.c:35
Application Task
This is an example that shows the use of a Barometer 4 Click board™. Logs the atmospheric pressure [ Pa ] and temperature [ degree Celsius ] data. Results are being sent to the Usart Terminal where you can track their changes.
{
static float pressure;
static float temperature;
log_printf( &logger, " Pressure : %.2f Pa\r\n", pressure );
log_printf( &logger, " Temperature : %.2f C\r\n", temperature );
log_printf( &logger, "----------------------------\r\n" );
Delay_ms ( 1000 );
}
void application_task(void)
Definition main.c:84
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.